package fechas;

import java.util.Calendar;
import java.util.GregorianCalendar;

/*
 * Manipula las fechas
 * 
 * */
public class DateManipulation {

	public DateManipulation(){
		
	}
	

	private int FirstDay(int year,int month,int day){
		Calendar pCal=java.util.GregorianCalendar.getInstance();
		pCal.set(GregorianCalendar.YEAR,year);
		pCal.set(GregorianCalendar.MONTH,month);
		pCal.set(GregorianCalendar.DAY_OF_WEEK,day);
		pCal.set(GregorianCalendar.DAY_OF_WEEK_IN_MONTH, 1);
		return pCal.get(GregorianCalendar.DAY_OF_MONTH);
	}
	
	private int LastDay(int year,int month,int day){
		Calendar pCal=java.util.GregorianCalendar.getInstance();
		pCal.set(GregorianCalendar.YEAR,year);
		pCal.set(GregorianCalendar.MONTH,month);
		pCal.set(GregorianCalendar.DAY_OF_WEEK,day);
		pCal.set(GregorianCalendar.DAY_OF_WEEK_IN_MONTH, -1);
		return pCal.get(GregorianCalendar.DAY_OF_MONTH);
	}
	
	
	private int anyWay(){
		Calendar pCal=java.util.GregorianCalendar.getInstance();
		pCal.set(GregorianCalendar.YEAR,2012);
		pCal.set(GregorianCalendar.MONTH,GregorianCalendar.APRIL);
		pCal.set(GregorianCalendar.DAY_OF_WEEK,GregorianCalendar.FRIDAY);
		pCal.set(GregorianCalendar.DAY_OF_WEEK_IN_MONTH, -1);
		return pCal.get(GregorianCalendar.DAY_OF_MONTH);
	}
	
	 public int total_dias(int year,int month, int day) {
		 return ((LastDay(year,month,day)-FirstDay(year,month,day))/7)+1;
     }


	
}
